public class MethodDemo4{
	//求1~n的和
	public static int sum(int n){
		if(n == 1)
			return 1;
		//在方法中强调方法本身---方法的递归
		//逆推
		return n * sum(n-1);
		
		
		
		
	}
	
	
	
	
	
	
	
	
	/*public static int sum(int n){
		
		int sum = 0;
		for(int i = 1; i <= n; i++){
			
			sum += i;
		}
		return sum;
	}
	*/
	
	
	
}